package com.bingxue.edu.management.education.model.aggregate;

import com.bingxue.edu.management.education.model.entity.exam.ExamAnswerRecord;
import com.bingxue.edu.management.education.model.entity.exam.ExamRecord;
import lombok.Data;

import java.math.BigDecimal;
import java.util.LinkedList;
import java.util.List;

/**
 * 考试记录聚合对象
 * 包含考生考试记录和考试答题记录
 */
@Data
public class ExamRecordAggregate {


    private ExamRecord examRecord;
    private List<ExamAnswerRecord> answerRecordList = new LinkedList<>();

    public BigDecimal computeTotalScore() {
        BigDecimal totalScore = BigDecimal.valueOf(0.0);
        for (ExamAnswerRecord answerRecord : answerRecordList) {
            totalScore = answerRecord.getScore().add(totalScore);
        }
        return totalScore;
    }
}
